<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title>罗米后台管理-后台管理</title>
		<link rel="stylesheet" href="/Public/css/pintuer.css">
		<link rel="stylesheet" href="/Public/css/admin.css">
		<script src="/Public/js/jquery.js"></script>
		<script src="/Public/js/pintuer.js"></script>
		<script src="/Public/js/respond.js"></script>
		<script src="/Public/js/admin.js"></script>
		<link type="image/x-icon" href="/favicon.ico" rel="shortcut icon" />
		<link href="/favicon.ico" rel="bookmark icon" />
		<base target="iframe" />
	</head>

<body>

	<div class="panel admin-panel">
		<div class="panel-head"><strong>栏目列表</strong>
		</div>
		<div class="padding border-bottom">
			<!--<input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="全选" />-->
			<a class="button button-small border-green" href="<?php echo U('Lmkj/Content/showAddContent');?>">添加顶级栏目</a>

			<!--<input type="button" class="button button-small border-yellow" value="批量删除" />-->
		</div>
		<table class="table table-hover">
			<tr cid=0>
				<th width="45"></th>
				<th width="45"></th>
				<th width="45">id</th>
				<th width="*">名称</th>
				<th width="200">时间</th>
				<th width="300">操作</th>
			</tr>
			<?php if(is_array($data)): foreach($data as $key=>$v): ?><tr cid='<?php echo ($v["cid"]); ?>' cateId='<?php echo ($v["category_id"]); ?>' isEnd="<?php echo ($v["_end"]); ?>" state="<?php echo ($v["state"]); ?>">
					<td>
						<input type="checkbox" name="id" value="<?php echo ($v["category_id"]); ?>" />
					</td>
					<td width="30"><a href="javascript:;" class="button button-little jiahao">+</a>
					</td>
					<td><?php echo ($v["category_id"]); ?></td>
					<td><?php echo ($v["_name"]); ?></td>
					<td><?php echo (date("y-m-d",$v["cate_time"])); ?></td>
					<td>
						<a class="button border-green button-little" href="<?php echo U('Lmkj/Content/showAddSonContent',array('id'=>$v['category_id']));?>">添加子栏目</a>
						<a class="button border-blue button-little" href="<?php echo U('Lmkj/Content/showAddContent',array('id'=>$v['category_id']));?>">修改</a>
						<a class="button border-yellow button-little del " href="javascript:;" data-id="<?php echo ($v["category_id"]); ?>">删除</a>
					</td>
				</tr><?php endforeach; endif; ?>

		</table>

	</div>
	<!--成功-->
	<div class="alert alert-green successInfo" style="width: 300px;display: none;position: absolute;">
		<span class="close rotate-hover"></span><strong>恭喜：</strong>操作成功。</div>
	<!--失败-->
	<div class="alert alert-yellow errorInfo" style="width: 300px;display: none;position: absolute;" ><span class="close rotate-hover  " ></span><strong>注意：</strong>操作失败，未知原因/先删除子栏目。</div>
	<!--加载-->
	<div class="alert alert-blue loadInfo" style="width: 300px;display: none;position: absolute;" ><span class="close rotate-hover " ></span>努力加载中...</div>

	
	<link type="text/css" rel="stylesheet" href="/Public/css/showBo.css" />
	<script type="text/javascript" src="/Public/js/showBo.js"></script>
	<script type="text/javascript">
		var APP = "/index.php";
		$(function() {
				// pid !=0  的全部隐藏	
				$('tr[cid != 0]').hide();
				$(".jiahao").each(function() {
						var _this = $(this)[0];
						_this.c = 0;
						state = $(this).parents('tr').attr('state');
						if (state == 'open') {
							$(this).removeAttr('class').html('');
						}
						$(this).click(function() {
							if (_this.c == 0) {
								$(this).html('-');
								//						让cid == cateId 显示
								_this.cateId = $(this).parents('tr').attr('cateId');
								$("tr[cid =" + _this.cateId + "]").show();
								_this.c = 1;
							} else {
								$(this).html('+');
								_this.cateId = $(this).parents('tr').attr('cateId');
								$("tr[cid =" + _this.cateId + "]").hide();
								_this.c = 0;
							}
						})
					})
					//删除
				$(".del").click(function() {
					var a = Showbo.Msg.confirm('您确定删除这条记录吗？');
					var id = $(this).attr('data-id');
					del(id);
				})
			})
			/**
			 * 设置到中间
			 */

		function setMiddle(cls) {
			//获得当前设置到中间
			var bWidth = $("body").width();
			var bHeight = $("body").height();
			//获得这个成功的消息
			var sWidth = $(cls).width();
			var sHeight = $(cls).height();
			var diffWidth = (bWidth - sWidth) / 2;
			var diffHeight = (bHeight - sHeight) / 2;
			$(cls).css({
				'top': diffHeight,
				'left': diffWidth,
				'zIndex': 1000
			}).show();
		}
		//删除
		function del(id){
			$("#dvMsgBtns .btn").eq(0).click(function(){
				$.ajax({
					type: "post",
					url: APP + "/Lmkj/Content/delCate",
					data: {
						'id': id
					},
					dataType: 'json',
					beforeSend: function() {
						setMiddle(".loadInfo");
					},
					success: function(data) {
						$(".loadInfo").hide();
						if (data) {
							setMiddle(".successInfo");
							window.location.reload();
						} else {
							setMiddle(".errorInfo");
						}
					}
				});
			})
		}
		
	</script>
</body>

</html>